app.controller('wzdjhyhxqCtrl',['$scope','wzdjhyhData','mainService','$location','$http',function ($scope,wzdjhyhData,mainService,$location,$http) {
    // $scope.item =[
    //     {
    //         "yinghuanjibie":"一般隐患A",
    //         "fxjb":"特别严重",
    //         "nj":"公司级",
    //         "yhcs":"安全部",
    //         "yhjtwz":"顶顶顶顶",
    //         "yhms":"2订单",
    //         "czcs":"防患",
    //         "tupian":"",
		// 	"zgsx":"2018-03-14",
		// 	"paicharen":"张三",
		// 	"paichariqi":"2018-02-14",
		// 	"fuzeren":"李鹏",
		// 	"yingjiyuan":"是是是",
    //         "zhenggaiyaoiu":"不合格",
    //     }
    // ];
    $scope.x= wzdjhyhData.getData();
    $scope.picPath =mainUrl+$scope.x.yhPicPath;
    console.log(wzdjhyhData.getData());
    var emeDeal = '';
    $scope.submit = function () {
        if(getInputs()==false){
            return;
        }
        mui.showLoading('加载中...','div');
        var token = localStorage.getItem('token');
        if(wzdjhyhData.getData().emeDeal!="应急预案(选填)"){
             emeDeal = wzdjhyhData.getData().emeDeal;
        }else{
            emeDeal = ''
        }
        $http({
            method: "POST",
            url: mainUrl + '/tr/tr-circle-reform-info-to!addTo.action',
            params: {
                'Authorization': token ,
                'reformName':$scope.fzr,
                'troRequire':$scope.zgyq,
                'reformId':mainService.getFzr().identityId,
                'version':1,
                'trpsid':$scope.x.zgjhSid,
                'delFlag':0,
                'tcrlsid':$scope.x.yhSid,
                'orpSid':mainService.getFzr().orpSid,
                'troMethod':$scope.zgcs,
                'emeDeal':emeDeal,
                'controlMeasures':wzdjhyhData.getData().controlMeasures

            }
        }).then(
            function (data, status, headers, config) {
                console.log(data);
                //$scope.data = data.data.items;
                if(data.data.success==false){

                    mui.hideLoading();
                }else{
                    mui.hideLoading();
                    mui.toast('提交成功');
                }

                // document.getElementsByClassName('mui-switch-blue').addEventListener
            }, function (data, status, headers, config) {
                console.log(data)
                console.log(status)
            })


        mainService.reset();
        $location.path('/weizhidingjihuayinhuan')
    }
    $scope.fzrtz = function ($event) {
        mainService.setFzrtz($event);
        $location.path('/renyuanxuanze')
    }
    $scope.fzr = mainService.getFzr().staffName;
    $scope.yjyabj = function ($event) {
        mainService.setYjyabj($event);
        $location.path('/daibanyingjiyuan')
    };
    $scope.yjya = mainService.getYjya().planName;
    $scope.onChange = function () {

        mainService.setArr({
            zgxq:$scope.zgxq,
            kzcs:$scope.kzcs,
            zgcs:$scope.zgcs
        });
        console.log(mainService.getArr())
    }
    if(mainService.getArr()[0]) {
        if (mainService.getArr()[0].zgxq) {
            $scope.zgxq = mainService.getArr()[0].zgxq;
            console.log($scope.zgxq)
        }
        if (mainService.getArr()[0].kzcs) {
            $scope.kzcs = mainService.getArr()[0].kzcs;
        }
        if (mainService.getArr()[0].zgcs) {
            $scope.zgcs = mainService.getArr()[0].zgcs;
        }

    }
    console.log(mainService.getYjya())
    $scope.showPic = function () {
        mui.showPic($scope.picPath,'div');
        // setTimeout(function () {
        //     mui.hidePic();
        // },1000)

    };
}]);